﻿using Microsoft.Extensions.DependencyInjection;
using ProductMonitor.UserControls;
using ProductMonitor.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ProductMonitor
{
    public class ServiceLocator
    {
        private IServiceProvider _serviceProvider;
        public MainWindowVM MainWindowVM => _serviceProvider.GetRequiredService<MainWindowVM>(); // 获取 MainWindowVM 实例
        public MonitorUCVM MonitorUCVM => _serviceProvider.GetRequiredService<MonitorUCVM>();// 获取 MonitorUCVM 实例

       
        public ServiceLocator()
        {
            var serviceCollection = new ServiceCollection();
         
            serviceCollection.AddSingleton<MainWindowVM>(); // 注册 MainWindowVM
            serviceCollection.AddSingleton<MonitorUCVM>(); // 注册 MainWindowVM
          
            // 初始化服务或资源
            _serviceProvider = serviceCollection.BuildServiceProvider();// 构建服务提供者
        }
        // 可以添加更多服务注册和解析方法
    }
}
